﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace VideoFlowStatistics
{
    public partial class MainNewForm : Form
    {
        public MainNewForm()
        {
            InitializeComponent();
        }

        private void MainNewForm_Load(object sender, EventArgs e)
        {
            if (Properties.Settings.Default.VideoType == "1")//单视屏
            {
                OneFMenuItem_Click(sender,e);
            }
            else if (Properties.Settings.Default.VideoType == "2")//多视屏
            {
                ManyFMenuItem_Click(sender, e);
            }
            this.LayoutMdi(MdiLayout.TileHorizontal);
            Class.AppClass.IsSaveVideo = SaveVideo.Checked;//设置保存视频
            //判断视频是否是正常记录状态
            if (Properties.Settings.Default.IsCollect != "0")
            {
                Properties.Settings.Default.IsCollect = "0";//0正常记录
                Properties.Settings.Default.Save();
            }
        }

        //线设置
        private void LineSetting_Click(object sender, EventArgs e)
        {
            FormLines lines = new FormLines();
            if (lines.ShowDialog() == DialogResult.OK)
            { }
        }

        private void OneFMenuItem_Click(object sender, EventArgs e)
        {
            // 排错判断：不能打开同一类型窗口
            foreach (Form frm in this.MdiChildren)
            {
                if (frm is MainForm)
                {
                    frm.Activate();
                    return;
                }
            }
            MainForm fm = new MainForm();
            fm.MdiParent = this;
            fm.Text = "单摄像头";
            fm.Show();
        }
        private void ManyFMenuItem_Click(object sender, EventArgs e)
        {
            foreach (Form frm in this.MdiChildren)
            {
                if (frm is FormManyImageComb)
                {
                    frm.Activate();
                    return;
                }
            }
            //又另一个多摄像头合成替换，暂停使用
            //FormMany fm = new FormMany();
            FormManyImageComb fm = new FormManyImageComb();
            fm.MdiParent = this;
            fm.Text = "多摄像头";
            fm.Show();
        }
        private void SearchList_Click(object sender, EventArgs e)
        {
            FormSearchList formsearch = new FormSearchList();
            if (formsearch.ShowDialog() == DialogResult.OK)
            { }
        }

        //保存画面
        private void SaveVideo_Click(object sender, EventArgs e)
        {
            Class.AppClass.IsSaveVideo = !Class.AppClass.IsSaveVideo;
            this.SaveVideo.Checked = Class.AppClass.IsSaveVideo;
        }

        //合成图位置参数设置
        private void ImageComb_Click(object sender, EventArgs e)
        {
            Dialogs.ImageComb imgComb = new Dialogs.ImageComb();
            Class.AppClass.IsLoad = true;
            if (imgComb.ShowDialog() == DialogResult.OK)
            { }
        }
    }
}
